package com.cerosoft.utils;

import java.util.ArrayList;
import java.util.List;

public class EventManager {

	public enum EventType {
		Prev, Next,
	}

	private List<IndexChangeListener> listeners = new ArrayList<IndexChangeListener>();

	public void addListener(IndexChangeListener listener) {
		listeners.add(listener);
	}

	public void removeListener(IndexChangeListener listener) {
		listeners.remove(listener);
	}

	public void removeAllListeners() {
		listeners.clear();
	}

	public EventManager() {
	}

	public void fireEvent(EventType type) {
		if (type == null) {
			return;
		}
		for (IndexChangeListener listener : listeners) {
			switch (type) {
			case Prev: {
				listener.indexSub();
				break;
			}
			case Next: {
				listener.indexAdd();
			}
			}
		}
	}

}
